package com.arkisv.common.util;

import com.arkisv.common.model.Page;
import org.springframework.beans.BeanUtils;

public class PageUtil {
	/** 默认显示条数(10) */
	public static final int DEFAULT_PAGE_SIZE = 10;
	/** 最大显示条数(100) */
	public static final int MAX_PAGE_SIZE = 100;

	/**
	 * 将结果集(list)封装成page对象
	 * @param list
	 * @return
	 * @mehtod: convertPage
	 * @Description: 将结果集(list)封装成page对象
	 */
	@SuppressWarnings("rawtypes")
	public static Object convertList2Page(Object list) {
		if (list instanceof com.github.pagehelper.Page) {
			Page page = new Page();
			com.github.pagehelper.Page pageHelper = (com.github.pagehelper.Page) list;
			try {
				BeanUtils.copyProperties(pageHelper, page);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return page;
		}
		return list;
	}

}
